<!DOCTYPE html>
<html>

<head lang="en">
  <meta charset="UTF-8">
  <title></title>
</head>

<body>
  <script>
    //匹配时间
    //23:59  02:07   2:7
    var pattern = /^(0?[0-9]|1[0-9]|2[0-3]):(0?[0-9]|[1-5][0-9])$/;
    var time = "02:07";
    console.log(pattern.test((time)));
  </script>
</body>

</html>